<!--<template>-->
<!--  <div class="mod-config">-->
<!--    <el-card class="search-box">-->
<!--      <div slot="header" class="clearfix">-->
<!--        <span>查询条件</span>-->
<!--        <el-button style="float: right; padding: 3px 0" @click="showAdvanced"-->
<!--                   v-bind:class="[searchBox.advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down']" type="text">展开高级查询</el-button>-->
<!--      </div>-->
<!--      <div>-->
<!--        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">-->
<!--          <el-form-item>-->
<!--            <el-input v-model="dataForm.key" size="small" placeholder="参数名" clearable></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item>-->
<!--            <el-input v-model="dataForm.key"  size="small"  placeholder="参数名" clearable></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item>-->
<!--            <el-input v-model="dataForm.key" size="small"  placeholder="参数名" clearable></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item>-->
<!--            <el-input v-model="dataForm.key" size="small"  placeholder="参数名" clearable></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item>-->
<!--            <el-button @click="getDataList()" icon="el-icon-search" size="small" >查询</el-button>-->
<!--          </el-form-item>-->
<!--          <div class="advanced-box" v-show="searchBox.advanced">-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item>-->
<!--              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>-->
<!--            </el-form-item>-->
<!--          </div>-->
<!--        </el-form>-->
<!--      </div>-->
<!--    </el-card>-->
<!--    <el-card class="data-box">-->
<!--      <div slot="header" class="clearfix">-->
<!--        <div class="button-box">-->
<!--          <div>-->
<!--            <el-button size="mini" class="el-button&#45;&#45;black" @click="getDataList()" icon="el-icon-refresh"></el-button>-->
<!--            <el-button size="mini" v-if="isAuth('bid:question:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>-->
<!--            <el-button size="mini" v-if="isAuth('bid:question:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>-->
<!--          </div>-->
<!--          <div>-->
<!--            <el-button-group>-->
<!--              <el-dropdown :hide-on-click="false">-->
<!--                <el-button size="mini" icon="el-icon-arrow-down el-icon&#45;&#45;right">列</el-button>-->
<!--                <el-dropdown-menu slot="dropdown">-->
<!--                  <el-dropdown-item v-for="field in defaultFormThead">-->
<!--                    <el-checkbox label="field.field" v-model="field.checked" @change="checkboxVal($event,field.field)">{{ field.label }}</el-checkbox>-->
<!--                  </el-dropdown-item>-->
<!--                </el-dropdown-menu>-->
<!--              </el-dropdown>-->
<!--              <el-button size="mini" v-if="isAuth('bid:question:save')" icon="el-icon-s-unfold" @click="addOrUpdateHandle()">导出</el-button>-->
<!--              <el-button size="mini" v-if="isAuth('bid:question:delete')" icon="el-icon-s-fold" @click="deleteHandle()">导入</el-button>-->
<!--            </el-button-group>-->
<!--          </div>-->
<!--        </div>-->
<!--      </div>-->
<!--      <el-table-->
<!--        :data="dataList"-->
<!--        border-->
<!--        v-loading="dataListLoading"-->
<!--        @selection-change="selectionChangeHandle"-->
<!--        style="width: 100%;">-->
<!--        <el-table-column-->
<!--          type="selection"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          width="50">-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="id"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="编码">-->
<!--        </el-table-column>-->
<!--        <el-table-column v-for="fruit in formThead" :key="fruit.field" :label="fruit.label" :prop="fruit.field" :header-align="fruit.header_align" :align="fruit.align">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row[fruit.label] }}-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          fixed="right"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          width="150"-->
<!--          label="操作">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>-->
<!--            <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--      </el-table>-->
<!--      <el-pagination-->
<!--        @size-change="sizeChangeHandle"-->
<!--        @current-change="currentChangeHandle"-->
<!--        :current-page="pageIndex"-->
<!--        :page-sizes="[10, 20, 50, 100]"-->
<!--        :page-size="pageSize"-->
<!--        :total="totalPage"-->
<!--        layout="total, sizes, prev, pager, next, jumper">-->
<!--      </el-pagination>-->
<!--    </el-card>-->
<!--    &lt;!&ndash; 弹窗, 新增 / 修改 &ndash;&gt;-->
<!--    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>-->
<!--  </div>-->
<!--</template>-->
<!--<script>-->
<!--  import AddOrUpdate from './question-add-or-update'-->
<!--  const defaultFormThead = [-->
<!--    {field: 'title', label: '提问标题', header_align: 'center', align: 'center', checked: true},-->
<!--    {field: 'content', label: '提问内容', header_align: 'center', align: 'center', checked: true},-->
<!--    {field: 'status', label: '状态', header_align: 'center', align: 'center', checked: true},-->
<!--    {field: 'remark', label: '备注', header_align: 'center', align: 'center', checked: true}-->
<!--  ];-->
<!--  export default {-->
<!--    data () {-->
<!--      return {-->
<!--        searchBox: {-->
<!--          advanced: false-->
<!--        },-->
<!--        dataForm: {-->
<!--          key: ''-->
<!--        },-->
<!--        dataList: [],-->
<!--        pageIndex: 1,-->
<!--        pageSize: 10,-->
<!--        totalPage: 0,-->
<!--        dataListLoading: false,-->
<!--        dataListSelections: [],-->
<!--        addOrUpdateVisible: false,-->
<!--        formThead: defaultFormThead.filter(i => i.checked === true),-->
<!--        defaultFormThead: defaultFormThead-->
<!--      }-->
<!--    },-->
<!--    components: {-->
<!--      AddOrUpdate-->
<!--    },-->
<!--    activated () {-->
<!--      this.getDataList()-->
<!--    },-->
<!--    methods: {-->
<!--      // 获取数据列表-->
<!--      getDataList () {-->
<!--        this.dataListLoading = true-->
<!--        this.$http({-->
<!--          url: this.$http.adornUrl('/bid/question/list'),-->
<!--          method: 'get',-->
<!--          params: this.$http.adornParams({-->
<!--            'page': this.pageIndex,-->
<!--            'limit': this.pageSize,-->
<!--            'key': this.dataForm.key-->
<!--          })-->
<!--        }).then(({data}) => {-->
<!--          if (data && data.code === 0) {-->
<!--            this.dataList = data.page.list-->
<!--            this.totalPage = data.page.totalCount-->
<!--          } else {-->
<!--            this.dataList = []-->
<!--            this.totalPage = 0-->
<!--          }-->
<!--          this.dataListLoading = false-->
<!--        })-->
<!--      },-->
<!--      // 每页数-->
<!--      sizeChangeHandle (val) {-->
<!--        this.pageSize = val-->
<!--        this.pageIndex = 1-->
<!--        this.getDataList()-->
<!--      },-->
<!--      // 当前页-->
<!--      currentChangeHandle (val) {-->
<!--        this.pageIndex = val-->
<!--        this.getDataList()-->
<!--      },-->
<!--      // 多选-->
<!--      selectionChangeHandle (val) {-->
<!--        this.dataListSelections = val-->
<!--      },-->
<!--      // 新增 / 修改-->
<!--      addOrUpdateHandle (id) {-->
<!--          // this.addOrUpdateVisible = true-->
<!--        // this.$nextTick(() => {-->
<!--        //   this.$refs.addOrUpdate.init(id)-->
<!--        // })-->
<!--        this.$router.push({-->
<!--          path: '/bid/question-add-edit'-->
<!--        })-->
<!--      },-->
<!--      // 删除-->
<!--      deleteHandle (id) {-->
<!--        var ids = id ? [id] : this.dataListSelections.map(item => {-->
<!--          return item.id-->
<!--        })-->
<!--        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {-->
<!--          confirmButtonText: '确定',-->
<!--          cancelButtonText: '取消',-->
<!--          type: 'warning'-->
<!--        }).then(() => {-->
<!--          this.$http({-->
<!--            url: this.$http.adornUrl('/bid/question/delete'),-->
<!--            method: 'post',-->
<!--            data: this.$http.adornData(ids, false)-->
<!--          }).then(({data}) => {-->
<!--            if (data && data.code === 0) {-->
<!--              this.$message({-->
<!--                message: '操作成功',-->
<!--                type: 'success',-->
<!--                duration: 1500,-->
<!--                onClose: () => {-->
<!--                  this.getDataList()-->
<!--                }-->
<!--              })-->
<!--            } else {-->
<!--              this.$message.error(data.msg)-->
<!--            }-->
<!--          })-->
<!--        })-->
<!--      },-->
<!--      // 切换高级查询-->
<!--      showAdvanced () {-->
<!--        this.searchBox.advanced = !this.searchBox.advanced-->
<!--      },-->
<!--      checkboxVal (val, field) {-->
<!--        console.log(val);-->
<!--        console.log(field);-->
<!--        this.defaultFormThead.map(item => {-->
<!--          if (field === item.field) {-->
<!--            this.$set(item, 'checked', val) // 这里，给对象添加属性，用$set方法。-->
<!--          }-->
<!--          return item-->
<!--        })-->
<!--        this.formThead = this.defaultFormThead.filter(i => i.checked === true)-->
<!--      }-->
<!--    }-->
<!--  }-->
<!--</script>-->

<template>
  <div class="mod-config">
    <el-card class="search-box">
      <div slot="header" class="clearfix">
        <span>查询条件</span>
        <el-button @click="showAdvanced"
                   v-bind:class="[searchBox.advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down','advanced']" type="text">展开高级查询</el-button>
      </div>
      <div>
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
          <el-form-item>
            <el-input v-model="dataForm.code" size="small" placeholder="项目编号" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="dataForm.key"  size="small"  placeholder="项目名称" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="dataForm.key" size="small"  placeholder="标段(包)编号" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="dataForm.key" size="small"  placeholder="标段(包)名称" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="getDataList()" icon="el-icon-search" size="small" >查询</el-button>
          </el-form-item>
          <div class="advanced-box" v-show="searchBox.advanced">
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </el-card>
    <el-card class="data-box">
      <div slot="header" class="clearfix">
        <div class="button-box">
          <div>
            <el-button size="mini" class="el-button--black" @click="getDataList()" icon="el-icon-refresh"></el-button>
            <el-button size="mini" type="primary" @click="addOrUpdateHandle()">文件澄清</el-button>
          </div>
          <div>
            <el-button-group>
              <el-dropdown :hide-on-click="false">
                <el-button size="mini" icon="el-icon-arrow-down el-icon--right">列</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="field in defaultFormThead">
                    <el-checkbox label="field.field" v-model="field.checked" @change="checkboxVal($event,field.field)">{{ field.label }}</el-checkbox>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
              <el-button size="mini" v-if="isAuth('bid:question:save')" icon="el-icon-s-unfold" @click="addOrUpdateHandle()">导出</el-button>
            </el-button-group>
          </div>
        </div>
      </div>
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        @selection-change="selectionChangeHandle"
        style="width: 100%;">
        <el-table-column
          prop="id"
          header-align="center"
          align="center"
          label="项目编码">
        </el-table-column>
        <el-table-column
          prop="projectId"
          header-align="center"
          align="center"
          label="项目名称">
        </el-table-column>
        <el-table-column
          prop="company"
          header-align="center"
          align="center"
          label="标段(包)编号">
        </el-table-column>
        <el-table-column
          prop="contacter"
          header-align="center"
          align="center"
          label="标段(包)名称">
        </el-table-column>
        <el-table-column
          prop="phone"
          header-align="center"
          align="center"
          label="状态">
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="150"
          label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
            <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </el-card>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
  import AddOrUpdate from './enrol-add-or-update'
  export default {
    data () {
      return {
        searchBox: {
          advanced: false
        },
        dataForm: {
          code: '',
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {
      AddOrUpdate
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/bid/enrol/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.$router.push({
          path: '/bid/question-list'
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/bid/enrol/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

      // 切换高级查询
      showAdvanced () {
        this.searchBox.advanced = !this.searchBox.advanced
      }
    }
  }
</script>
